package org.web.common.sso.demo.controller;

import com.google.gson.Gson;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.web.common.sso.client.biz.impl.PropertiesConstantInterface;
import org.web.common.sso.client.domain.SessionAccountDO;
import org.web.common.sso.client.helper.SSOHelper;

@Controller
@RequestMapping("helloDemo")
class HelloDemoController {

    /***
     *
     * */
    @RequestMapping(value = "getFirstWorld", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String getFirstWorld(String ssoToken) {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        //attributes.getAttributeNames(0)
        SessionAccountDO sessionAccountDO = SSOHelper.getSessionAccountDO();
        System.out.println();
        return "welcome first sso app. 登录用户是："+ (new Gson()).toJson(sessionAccountDO);
    }

    @RequestMapping(value = "ignoreUrl", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String ignoreUrl(String ssoToken) {
        return "welcome first sso app. it's ignoreUrl ";
    }

}
